<?php

namespace App\Http\Controllers\Admin;

use App\Services\RankService;
use Illuminate\Http\Request;
use App\Models\PlayerRecord;
use App\Http\Controllers\Controller;

class RankController extends Controller
{

    //获取玩家得分排行
    public function index(Request $request)
    {
        $season = (int)$request->query('season', env('KILL_SEASON'));

        return app()
            ->get(RankService::class)
            ->index($season);
    }

    /**
     * 玩家游戏记录
     */
    public function show(int $id)
    {
        return PlayerRecord::query()
                           ->with('player')
                           ->where('player_id', $id)
                           ->where('season', env('KILL_SEASON'))
                           ->orderBy('record_id', 'desc')
                           ->get();
    }
}
